package com.oocl.ita.parser;

import com.oocl.ita.handler.ChatHandler;
import com.oocl.ita.handler.IHandler;
import com.oocl.ita.handler.InvalidHandler;
import com.oocl.ita.handler.ShakeHandler;
import com.oocl.ita.handler.SynHandler;
import com.oocl.ita.qqclientt.QQClient;
import com.oocl.ita.sakura.protocol.Protocol;

public  class Parser {

	
	public IHandler parse(Protocol protocol){
		String msgType = protocol.getMsgType();
		IHandler handler = null;
		switch(msgType.toLowerCase()) {
		case "syn" :System.out.println("Parser : "  + QQClient.getClient() +" syn");
		handler = new SynHandler();
		break;
		case "chat" : System.out.println("Parser : " + QQClient.getClient() +" chat");
		handler = new ChatHandler();
		break;
		case "shake" : System.out.println("Parser : " + QQClient.getClient() + "shake");
		handler = new ShakeHandler();
		break;
		default :
			System.out.println("Parser : " + QQClient.getClient() +" Invalid Command");
			handler = new InvalidHandler();
		}
		return handler;
	}
}
